blob: acf6a37026bd2236d814ab43559fc8e5cc6e98cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { auth, get } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
export async function load({ cookies, params, parent }) {
const { user } = await parent();
const aid = cookies.get("aid") || user.id;
const { address, amount } = params;
const account = await get(`/account/${aid}`, auth(cookies));
const senderIsVault = account.pubkey || account.seed;
let invoice;
try {
invoice = await get(`/invoice/${address}`);
} catch {
// invoice not found
}
if (invoice && !senderIsVault) {
const isVault = invoice.account?.pubkey || invoice.account?.seed;
if (isVault) {
// Vault account — stay on /send/bitcoin for on-chain send
} else {
// Custodial account — send internally via the original invoice
if (invoice.uid !== user.id) redirect(307, `/send/invoice/${invoice.id}`);
}
}
return { balance: account.balance };
}
|